package com.ruoyi.project.channel.clickFormUser.service;

import java.util.List;

import com.ruoyi.framework.shiro.service.PasswordService;
import com.ruoyi.project.system.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.channel.clickFormUser.mapper.ClickFormUserMapper;
import com.ruoyi.project.channel.clickFormUser.domain.ClickFormUser;
import com.ruoyi.project.channel.clickFormUser.service.IClickFormUserService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 刷单用户 服务层实现
 * 
 * @author CAIN
 * @date 2021-01-24
 */
@Service
public class ClickFormUserServiceImpl implements IClickFormUserService 
{
	@Autowired
	private ClickFormUserMapper clickFormUserMapper;
	@Autowired
	private PasswordService passwordService;
	/**
     * 查询刷单用户信息
     * 
     * @param userId 刷单用户ID
     * @return 刷单用户信息
     */
    @Override
	public ClickFormUser selectClickFormUserById(Long userId)
	{
	    return clickFormUserMapper.selectClickFormUserById(userId);
	}
	
	/**
     * 查询刷单用户列表
     * 
     * @param clickFormUser 刷单用户信息
     * @return 刷单用户集合
     */
	@Override
	public List<ClickFormUser> selectClickFormUserList(ClickFormUser clickFormUser)
	{
	    return clickFormUserMapper.selectClickFormUserList(clickFormUser);
	}
	
    /**
     * 新增刷单用户
     * 
     * @param clickFormUser 刷单用户信息
     * @return 结果
     */
	@Override
	public int insertClickFormUser(ClickFormUser clickFormUser, User user)
	{
		clickFormUser.setUserId(user.getUserId());
		clickFormUser.setSalt(user.getSalt());
		clickFormUser.setStatus("0");
		clickFormUser.setPayPwd(passwordService.encryptPassword(user.getLoginName(), clickFormUser.getPayPwd(), user.getSalt()));
	    return clickFormUserMapper.insertClickFormUser(clickFormUser);
	}
	
	/**
     * 修改刷单用户
     * 
     * @param clickFormUser 刷单用户信息
     * @return 结果
     */
	@Override
	public int updateClickFormUser(ClickFormUser clickFormUser)
	{
	    return clickFormUserMapper.updateClickFormUser(clickFormUser);
	}

	/**
     * 删除刷单用户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteClickFormUserByIds(String ids)
	{
		return clickFormUserMapper.deleteClickFormUserByIds(Convert.toStrArray(ids));
	}
	
}
